//
//  NSDictionary
//  testone
//
//  Created by Colin on 15/1/23.
//  Copyright (c) 2015年 Colin. All rights reserved.
//

#import "NSDictionary+Extension.h"

@implementation NSDictionary(Extension)

-(BOOL)CheckNSDictionaryData
{
    if (self && [self isKindOfClass:[NSDictionary class]] && self.allKeys.firstObject != [NSNull null]) {
        return YES;
    }
    return NO;
}

//字典转json
- (NSString *)jsonStringWithDictionary:(NSDictionary *)dictionary{

    NSString *jsonStr = @"{";

    NSArray * keys = [dictionary allKeys];

    for (NSString * key in keys) {

        jsonStr = [NSString stringWithFormat:@"%@\"%@\":\"%@\",",jsonStr,key,[dictionary objectForKey:key]];

    }

    jsonStr = [NSString stringWithFormat:@"%@%@",[jsonStr substringWithRange:NSMakeRange(0, jsonStr.length-1)],@"}"];

    return jsonStr;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
